import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 10 - 10
 * Time: 21:45
 */
//牛客 两种排序方法
public class Solution3 {
    public static void main(String[] args) throws IOException {
        //BufferedReader的作用是从字符流中读取文本并且进行缓存
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = reader.readLine();
        }
        if(isSortZidian(arr) && isSortLength(arr)) {
            System.out.println("both");
        }else if (isSortZidian(arr)) {
            System.out.println("lexicographically");
        } else if (isSortLength(arr)) {
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }
    }
    public static boolean isSortZidian(String[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
           if(arr[i].compareTo(arr[i + 1]) > 0) {
               return false;
           }
        }
        return true;
    }
    public static boolean isSortLength(String[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            if(arr[i].length() > arr[i + 1].length()) {
                return false;
            }
        }
        return true;
    }
}
